#ifndef __OLLYLUA_ODLOGWINDOW_H__
#define __OLLYLUA_ODLOGWINDOW_H__

#include <vector>
#include <luabind/luabind.hpp>
#include <luabind/lua_include.hpp>

#include "Plugin.h"
#include "singleton.hpp"

struct t_log_data /*: public t_sortheader*/
{
	ulong line;
	ulong size;
	ulong type;
	ulong addr;
	char message[TEXTLEN];
	t_log_data()
	{
		memset(this, 0, sizeof(*this));
		size = 1;
	}
};
class ODLogWindow : public Singleton<ODLogWindow>
{
	friend class Singleton<ODLogWindow>;
public:
	ODLogWindow();
	~ODLogWindow();
	bool Initialize(lua_State* lua_state);
	void Finalize();
	void ShowWindow();
	inline t_table* get_od_table(){ return &od_table_; }
private:
	void Log(ulong address, std::string msg);
	void ClearLog();
private:
	static LRESULT CALLBACK LogWindowProc(HWND hw,UINT msg,WPARAM wp,LPARAM lp);
	static int DrawTable(char *s, char *mask, int *select, t_sortheader *ph, int column);
	static int SortFunction(const t_sortheader *p1,const t_sortheader *p2,const int sort);
private:
	char class_name_[32];
	t_table od_table_;
	std::vector<t_log_data> od_logs_;
};
#define sODLogWindow ODLogWindow::GetInstance()
#endif//__OLLYLUA_ODLOGWINDOW_H__